<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
function init_Password($password) {
    $salt = '5^7*ban$V%^#@wM';
    return md5($password . $salt);
}

function setMsg($status, $message, $data=[], $httpCode=200) {
    $result = [
        'status' => $status,
        'message' => $message,
        'data' => $data
    ];
    return json($result, $httpCode);
}

function bootstrap_table_return($rows, $data) {
    $return_data = array_values($data);
    $result = [
        'total' => $rows,
        'rows' => $return_data
    ];
    return json($result);
}

function billno() {
    $ymCode = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
    list($t1) = explode(' ', microtime());
    $micro_str = substr($t1, 2,3);
    $billno = $ymCode[intval(date('Y')) - 2017] . $ymCode[intval(date('m'))] . date('dHis') . $micro_str . mt_rand(100, 999);
    return $billno;
}
